﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>DocAdmin</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="${request.contextPath}/lib/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="${request.contextPath}/lib/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${request.contextPath}/lib/lte/dist/css/AdminLTE.min.css">

    <!--[if lt IE 9]>
    <script type="text/javascript" src="${request.contextPath}/res/js/html5shiv.min.js"></script>
    <script type="text/javascript" src="${request.contextPath}/res/js/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="${request.contextPath}/res/font/googleapis/fonts.css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
<body class="hold-transition login-page">
<div style="background-color: #FAFAF9">

    <div class="login-box">
        <div class="login-logo">
            <a href="#"><b>Sea</b>Admin</a>
        </div>
        <#-- /.login-logo -->
        <div class="login-box-body">
            <p class="login-box-msg">注册账号</p>

            <form id="loginForm" class="layui-form">
                <div class="form-group has-feedback">
                    <input type="text" name="username" class="form-control" autocomplete="off" placeholder="账号">
                    <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
                </div>
                <p class="text-muted">&nbsp;</p>
                <div class="form-group has-feedback">
                    <input type="password" name="password" class="form-control" autocomplete="off" placeholder="密码">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                </div>
                <div class="form-group has-feedback">
                    <input type="password" name="pwd" class="form-control" autocomplete="off" placeholder="重新输入">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                </div>
                <div class="row">
                    <div class="col-xs-4">
                        <button type="button" class="btn btn-block btn-block btn-flat" onclick="window.history.go(-1)">
                            返回
                        </button>
                    </div>
                    <div class="col-xs-4">
                    </div>
                    <div class="col-xs-4">
                        <button type="button" id="submit" class="btn btn-primary btn-block btn-flat">确定</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <footer>
        <div class="pull-right hidden-xs">
            Recommend using Google Chrome &nbsp;
        </div>
        &nbsp;<strong>Copyright &copy; <a href="https://gitee.com/seaboot/seaboot-admin">Mr.css</a>.</strong>
        All rights reserved.<b>Version</b> 1.0.0
    </footer>

    <!-- jQuery/Bootstrap/SlimScroll/FastClick/AdminLTE -->
    <script type="text/javascript" src="${request.contextPath}/lib/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="${request.contextPath}/lib/lte/dist/js/adminlte.min.js"></script>
    <script type="text/javascript" src="${request.contextPath}/lib/layer/layer.js"></script>
    <script type="text/javascript" src="${request.contextPath}/lib/bootstrap/dist/js/bootstrap.min.js"></script>

    <script>
        $(function () {
            if (window !== top) {
                top.location.href = location.href;
            }
            layui.use(['layer', 'form'], function () {
                var layer = layui.layer
                    , form = layui.form;

                $('#submit').click(function (evt) {
                    let res = new FormData(document.getElementById('loginForm'));
                    let username = res.get('username');
                    if (username.trim().length === 0) {
                        layer.alert('用户名不允许为空！');
                        return;
                    }

                    let password = res.get('password');
                    if (password.trim().length === 0) {
                        layer.alert('密码不允许为空！');
                        return;
                    }let pwd = res.get('pwd');
                    if (password !== pwd) {
                        layer.alert('密码两次输入不一致！');
                        return;
                    }

                    $.ajax({
                        cache: false,
                        type: "POST",
                        url: '${request.contextPath}/sys/user/register',
                        data: {username: username, password: password},
                        dataType: 'json'
                    }).done(function (result) {
                        if (result.code !== 0) {
                            layer.alert(result.data);
                        } else {
                            location.href = '${request.contextPath}/index.ftl';
                        }
                    });
                });
            });
        })
    </script>
</div>
</body>
</html>
